package leaveSystem.model;

import java.io.Serializable;
import java.util.Date;


public class Role implements Cloneable, Serializable {

    private int roleId;
    private String roleName;
    private String description;
    private String createdBy;
    private Date createdTimeStamp;


    public Role () {

    }

    public Role (int roleIdIn) {

          this.roleId = roleIdIn;

    }


    public int getRoleId() {
          return this.roleId;
    }
    public void setRoleId(int roleIdIn) {
          this.roleId = roleIdIn;
    }

    public String getRoleName() {
          return this.roleName;
    }
    public void setRoleName(String roleNameIn) {
          this.roleName = roleNameIn;
    }

    public String getDescription() {
          return this.description;
    }
    public void setDescription(String descriptionIn) {
          this.description = descriptionIn;
    }

    public String getCreatedBy() {
          return this.createdBy;
    }
    public void setCreatedBy(String createdByIn) {
          this.createdBy = createdByIn;
    }

    public Date getCreatedTimeStamp() {
          return this.createdTimeStamp;
    }
    public void setCreatedTimeStamp(Date createdTimeStampIn) {
          this.createdTimeStamp = createdTimeStampIn;
    }


    public void setAll(int roleIdIn,
          String roleNameIn,
          String descriptionIn,
          String createdByIn,
          Date createdTimeStampIn) {
          this.roleId = roleIdIn;
          this.roleName = roleNameIn;
          this.description = descriptionIn;
          this.createdBy = createdByIn;
          this.createdTimeStamp = createdTimeStampIn;
    }

    public boolean hasEqualMapping(Role valueObject) {

          if (valueObject.getRoleId() != this.roleId) {
                    return(false);
          }
          if (this.roleName == null) {
                    if (valueObject.getRoleName() != null)
                           return(false);
          } else if (!this.roleName.equals(valueObject.getRoleName())) {
                    return(false);
          }
          if (this.description == null) {
                    if (valueObject.getDescription() != null)
                           return(false);
          } else if (!this.description.equals(valueObject.getDescription())) {
                    return(false);
          }
          if (this.createdBy == null) {
                    if (valueObject.getCreatedBy() != null)
                           return(false);
          } else if (!this.createdBy.equals(valueObject.getCreatedBy())) {
                    return(false);
          }
          if (this.createdTimeStamp == null) {
                    if (valueObject.getCreatedTimeStamp() != null)
                           return(false);
          } else if (!this.createdTimeStamp.equals(valueObject.getCreatedTimeStamp())) {
                    return(false);
          }

          return true;
    }

    public String toString() {
        StringBuffer out = new StringBuffer("");
        out.append("\nclass Role, mapping to table role\n");
        out.append("Persistent attributes: \n"); 
        out.append("roleId = " + this.roleId + "\n"); 
        out.append("roleName = " + this.roleName + "\n"); 
        out.append("description = " + this.description + "\n"); 
        out.append("createdBy = " + this.createdBy + "\n"); 
        out.append("createdTimeStamp = " + this.createdTimeStamp + "\n"); 
        return out.toString();
    }


    public Object clone() {
        Role cloned = new Role();

        cloned.setRoleId(this.roleId); 
        if (this.roleName != null)
             cloned.setRoleName(new String(this.roleName)); 
        if (this.description != null)
             cloned.setDescription(new String(this.description)); 
        if (this.createdBy != null)
             cloned.setCreatedBy(new String(this.createdBy)); 
        if (this.createdTimeStamp != null)
             cloned.setCreatedTimeStamp((Date)this.createdTimeStamp.clone()); 
        return cloned;
    }


}
